<?php
	//DICOM data root - absolute path
	$dicom_worker = "master.htm";
	$dicom_root = "/data";
	$full_dicom_root = $_SERVER['DOCUMENT_ROOT'] . $dicom_root;
?>

<!DOCTYPE html>
<html>
<head>
	<title>MRI Michaela Zahradníková</title>
</head>
<body>
<h1>Pořízené MRI sety</h1>
<p>
<?php
	$dirs = array_diff(scandir($full_dicom_root), array('..', '.'));
	foreach($dirs as $dir) {
		$full_dir_path = $full_dicom_root . "/" . $dir;
		if (is_dir($full_dir_path) && (substr($dir,0,1) != ".")) {
			$files = array_diff(scandir($full_dir_path), array('..', '.'));
			$uri_path = "";
			foreach($files as $fil) {
				if (is_file($full_dir_path . "/" . $fil)  && (substr($fil,0,1) != ".")) {
					$uri_path .= ("&file=" . $fil);
				}
			}
			$uri_path = rawurlencode($dicom_root . "/" . $dir . "/" . "?" . substr($uri_path, 1));
			$uri_path = $dicom_worker . "?input=" . $uri_path . "&dwvReplaceMode=void";
		?>
		<a href="<?php echo($uri_path); ?>"><?php echo($dir); ?></a><br />
		<?php
		}
	}
?>
</p>
<p><a href="html/study.htm">HTML version</a></p>
</body>
</html>
		